<template>
  <div>
    <van-nav-bar title="lodash.js示例" class="nav-bar" left-arrow @click-left="navToBack"/>
    <div class="content">
      <div class="block">
        <van-row>
          <van-col span="8"><van-button type="info" @click="onRemove()">_.remove</van-button></van-col>
          <van-col span="8"><van-button type="info"  @click="onMap()">_.map</van-button></van-col>
        </van-row>
      </div>

    </div>
  </div>
</template>
<script>
import common from '@/mixins/common'
import _ from 'lodash'

export default {
  mixins: [common],
  methods: {
    // _.remove
    onRemove () {
      const list = [{ id: 1, name: '第一个' }, { id: 2, name: '第二个' }]
      _.remove(list, function (n) { return n.id === 1 })
      console.log(list)
    },
    // _.map
    onMap () {
      const list = [{ id: 1, name: '第一个' }, { id: 2, name: '第二个' }]
      _.map(list, (n, index) => {
        if (n.id === 1) {
          n.name = '第一个修改了'
        }
        console.log(n, index)
      })
    }
  }
}
</script>
